import {
    USER_KEY
} from './constant'

export const throttle = (fn, time = 300) => {
    let timer
    return () => {
        if (timer) {
            return
        }
        timer = setTimeout(() => {
            timer = null
            fn()
        }, time)
    }
}

export function getUser() {
    const user = localStorage.getItem(USER_KEY)
    if (user) return JSON.parse(user)
    return null
}